package com.jinly.ryder.monitor.service.model;


import com.jinly.ryder.common.service.model.BaseEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

@Getter
@AllArgsConstructor
public enum MonitorKeyType implements BaseEnum {

    HEALTH_STATUS("health.status", "健康状态"),
    HEALTH_STATUS_REGISTRY("health.status.registry", "服务注册状态"),

    JVM_MEMORY_MAX("jvm.memory.max", "JVM最大内存"),
    JVM_MEMORY_USED("jvm.memory.used", "JVM已用内存"),
    JVM_MEMORY_COMMITTED("jvm.memory.committed", "JVM可用内存"),

    JVM_THREADS_PEAK("jvm.threads.peak", "JVM峰值线程数"),
    JVM_THREADS_LIVE("jvm.threads.live", "JVM当前活跃线程数"),
    JVM_THREADS_DAEMON("jvm.threads.daemon", "JVM守护线程数"),

    JVM_GC_PAUSE("jvm.gc.pause", "GC耗时"),

    SYSTEM_LOAD_AVERAGE("system.load.average.1m", "系统负载"),
    SYSTEM_CPU_USAGE("system.cpu.usage", "系统CPU使用率"),

    PROCESS_CPU_USAGE("process.cpu.usage", "当前进程CPU使用率"),
    ;

    private String key;
    private String name;

    public static MonitorKeyType of(String code) {
        MonitorKeyType[] types = MonitorKeyType.values();
        for (MonitorKeyType type : types) {
            if (Objects.equals(type.getCode(), code)) {
                return type;
            }
        }
        return null;
    }
}
